<template>
  <div class="home-box">
    <el-table
      :data="tableData"
      style="width: 100%">
      <el-table-column
        prop="title"
        label="标题"
      >
      </el-table-column>
      <el-table-column
        prop="author"
        label="作者"
        >
      </el-table-column>
      <el-table-column
        prop="create_time"
        label="创建日期">
      </el-table-column>
      <el-table-column
        prop="update_time"
        label="更新日期">
      </el-table-column>
      <el-table-column
        prop="oper"
        label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="view(scope.row)">详情</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>
<script>
    export default {
      data() {
        return {
          tableData: []
        }
      },
      // asyncData限于页面组件使用
      async asyncData(txt) {
        const res = await txt.$api.articleList({ page: 1, size: 10 })
        let tableData = []
        if(res.code === 200) {
          tableData = res.data.data
        }
        return { tableData }
      },
      methods: {
        view (row) {
          this.$router.push('/article/' + row.id)
        }
      }
    }
  </script>
<style lang="scss" scoped>
</style>